const std = @import("std");
const Cell = @import("cell.zig");

pub fn removeDeadCell(list: *std.ArrayList(*Cell)) void {
    const item_size = list.items.len;
    for (0..item_size) |idx| {
        var cell = list.items[item_size - idx - 1];
        if (!cell.alive) {
            cell.grid_cell.?.remove(cell);
            cell.deinit();
            _ = list.swapRemove(item_size - idx - 1);
            list.allocator.destroy(cell);
        }
    }
}
